import { createActions } from '@axios'
import api from '@/api/corp-manage'

const module = {
  namespaced: true,
  state: {
    token: sessionStorage.getItem('GdToken') || '',
    userInfo: sessionStorage.getItem('userInfo') || '',
    loginTime: '',
    currentRouter: [],
  },
  mutations: {
    // 设置token
    setToken(state, payload) {
      state.token = payload
      sessionStorage.setItem('GdToken', payload)
    },
    // 设置用户信息
    setUserInfo(state, payload) {
      state.userInfo = payload
      sessionStorage.setItem('userInfo', payload)
    },
    // 设置登录时间
    setLoginTime(state, payload) {
      state.loginTime = payload
    },
    // 清除token
    removeToken(state, payload) {
      sessionStorage.removeItem('GdToken')
      state.token = payload
    },
  },
  actions: createActions({
    ...api,
  }),
  getters: {},
}

export default module
